<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" />
  </body>
  <script>
    //防抖 debounce 是一种策略
    //事件触发了,延迟n秒后再执行回调,在n秒内如果该事件又触发了,则需要重新计时
    //好处,对于
    let timeId
    document.querySelector('input').oninput = function () {
      clearTimeout(timeId)
      timeId = setTimeout(() => {
        console.log(this.value)
      }, 300)
    }
  </script>
</html>
